package xyz.geminiwen.skinsprite.view;

import ohos.agp.components.AttrSet;
import ohos.agp.components.DependentLayout;
import ohos.agp.components.element.Element;
import ohos.app.Context;

/**
 * Created by geminiwen on 16/6/16.
 * TODO change divider
 */
public class SkinnableDepentLayout extends DependentLayout implements Skinnable {
    
    private final AttrSet attrs;

    public SkinnableDepentLayout(Context context) {
        this(context, null);
    }

    public SkinnableDepentLayout(Context context, AttrSet attrs) {
        this(context, attrs, null);
    }

    public SkinnableDepentLayout(Context context, AttrSet attrs, String defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.attrs = attrs;
    }

    @Override
    public void applyDayNight() {
        if (attrs != null) {
            attrs.getAttr(AttrsHelper.ATTR_BG).ifPresent(attr -> {
                Element element = attr.getElement();
                if (element != null) {
                    setBackground(element);
                }
            });
        }
    }

    @Override
    public boolean isSkinnable() {
        return true;
    }

    @Override
    public void setSkinnable(boolean skinnable) {
    }
}
